package org.apache.commons.pool2.impl;

import java.security.AccessControlException;

/**
 * 类的描述
 *
 * @author ztkool
 * @version v
 */
public final class CallStackUtils {

    private static boolean canCreateSecurityManager() {
        SecurityManager manager = System.getSecurityManager();
        if (manager == null) {
            return true;
        } else {
            try {
                manager.checkPermission(new RuntimePermission("createSecurityManager"));
                return true;
            } catch (AccessControlException var2) {
                return false;
            }
        }
    }

    /**
     * @deprecated
     */
    @Deprecated
    public static CallStack newCallStack(String messageFormat, boolean useTimestamp) {
        return newCallStack(messageFormat, useTimestamp, false);
    }

    public static CallStack newCallStack(String messageFormat, boolean useTimestamp, boolean requireFullStackTrace) {
        return (CallStack) (canCreateSecurityManager() && !requireFullStackTrace ? new SecurityManagerCallStack(messageFormat, useTimestamp) : new ThrowableCallStack(messageFormat, useTimestamp));
    }

    private CallStackUtils() {
    }
}
